<?php

/**
 * countries actions.
 *
 * @package    sf_sandbox
 * @subpackage countries
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
 */
class countriesActions extends sfActions
{
  public function executeIndex()
  {
    $this->countriesList = CountriesPeer::doSelect(new Criteria());
  }

  public function executeCreate()
  {
    $this->form = new CountriesForm();

    $this->setTemplate('edit');
  }

  public function executeEdit($request)
  {
    $this->form = new CountriesForm(CountriesPeer::retrieveByPk($request->getParameter('countries_id')));
  }

  public function executeUpdate($request)
  {
    $this->forward404Unless($request->isMethod('post'));

    $this->form = new CountriesForm(CountriesPeer::retrieveByPk($request->getParameter('countries_id')));

    $this->form->bind($request->getParameter('countries'));
    if ($this->form->isValid())
    {
      $countries = $this->form->save();

      $this->redirect('countries/edit?countries_id='.$countries->getCountriesId());
    }

    $this->setTemplate('edit');
  }

  public function executeDelete($request)
  {
    $this->forward404Unless($countries = CountriesPeer::retrieveByPk($request->getParameter('countries_id')));

    $countries->delete();

    $this->redirect('countries/index');
  }
}
